﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Crossroad.Utils.Extensions
{
    /// <summary>
    /// double型类型扩展
    /// </summary>
    public static class DoubleExt
    {
        /// <summary>
        /// 转int类型
        /// </summary>
        /// <returns></returns>
        public static int ToInt(this double input)
        {
            return Convert.ToInt32(input);
        }

        /// <summary>
        /// 转int类型
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static int ToInt(this double? input)
        {
            if (input.IsNull())
                return 0;

            return Convert.ToInt32(input);
        }

        /// <summary>
        /// 转decimal
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static decimal ToDecimal(this double input)
        {
            return Convert.ToDecimal(input);
        }


    }
}

